home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Security / Ashampoo AntiVirus 1.61 / ashampoo_antivirus161_sm.exe / {app} / AshAV.gadget / js / settings.js < prev   
Text (UTF-16)  |  2007-08-29  |  18KB  |  293 lines

  1. //AV Gadget
  2. //<C> 2007 Ashampoo GmbH & Co K.G.
  3.  
  4. var mySetting = new clockSettings();
  5.  
  6. var L_PREVIOUS_TEXT = "Previous";
  7. var L_NEXT_TEXT = "Next";
  8.  
  9. var imagePath = "images/";
  10. var imageArray = new Array("bg_progress_empty.png");
  11. var imageIndex = 0;
  12.  
  13. var oShell = new ActiveXObject("WScript.Shell");
  14.  
  15. var stxt1="", stxt2="", stxt3="", stxt4="", stxt5="", stxt6="", stxt7="";
  16. //////var bChk1,bChk2,bChk3,bChk4,bChk5,bChk6;
  17. var scanaction = 4;
  18.  
  19. ////////////////////////////////////////////////////////////////////////////////
  20. // load settings
  21. ////////////////////////////////////////////////////////////////////////////////
  22. function loadSettings()
  23. {
  24.     var pageDir = document.getElementsByTagName("html")[0].dir;
  25.     
  26.     if (pageDir == "rtl")
  27.     {
  28.         settingsButtonTable.dir = "rtl";
  29.         
  30.         var temp = settingsButtonLeftCell.innerHTML;
  31.         settingsButtonLeftCell.innerHTML = settingsButtonRightCell.innerHTML;
  32.         settingsButtonRightCell.innerHTML = temp;
  33.         
  34.         temp = settingsImageLeft.onmousedown;
  35.         settingsImageLeft.onmousedown = settingsImageRight.onmousedown;
  36.         settingsImageRight.onmousedown = temp;
  37.         
  38.         temp = settingsLeftAnchor.onkeypress;
  39.         settingsLeftAnchor.onkeypress = settingsRightAnchor.onkeypress;
  40.         settingsRightAnchor.onkeypress = temp;
  41.  
  42.         settingsImageLeft.alt = L_NEXT_TEXT;
  43.         settingsImageRight.alt = L_PREVIOUS_TEXT;
  44.     }
  45.     else
  46.     {
  47.         settingsImageLeft.alt = L_PREVIOUS_TEXT;
  48.         settingsImageRight.alt = L_NEXT_TEXT;
  49.     }
  50.     
  51.  
  52.     
  53.  
  54.     var lm = "HKLM\\Software\\Ashampoo\\Ashampoo AntiVirus\\";
  55.     var text1="", text2="", text3="", text4="", text5="", text6="";
  56.     var gtxt1="", gtxt2="", gtxt3="";
  57.  
  58.     //Set texts according to language choosen (ashavsrv.exe conveniently writes them in the registry)
  59.     try
  60.     {
  61.     text1 = oShell.RegRead(lm + "gOption1");
  62.     text2 = oShell.RegRead(lm + "gOption2");
  63.     text3 = oShell.RegRead(lm + "gOption3");
  64.     text4 = oShell.RegRead(lm + "gOption4");
  65.     text5 = oShell.RegRead(lm + "gOption5");
  66.     text6 = oShell.RegRead(lm + "gOption6");
  67.     gtxt1 = oShell.RegRead(lm + "gText1");
  68.     gtxt2 = oShell.RegRead(lm + "gText2");
  69.     gtxt3 = oShell.RegRead(lm + "gText3");
  70.     }
  71.     catch(err) { }
  72.  
  73.     try
  74.     {
  75.     stxt1 = oShell.RegRead(lm + "gScan1");
  76.     stxt2 = oShell.RegRead(lm + "gScan2");
  77.     stxt3 = oShell.RegRead(lm + "gScan3");
  78.     stxt4 = oShell.RegRead(lm + "gScan4");
  79.     stxt5 = oShell.RegRead(lm + "gScan5");
  80.     stxt6 = oShell.RegRead(lm + "gScan6");
  81.     stxt7 = oShell.RegRead(lm + "gScan7");
  82.     loadActions();
  83.     }
  84.     catch(err) 
  85.     {
  86.     stxt1 = "Scan Removables";
  87.     stxt2 = "Scan Memory";
  88.     stxt3 = "Scan System Areas"
  89.     stxt4 = "Scan Entire System";
  90.     stxt5 = "Scan Hard Drives";
  91.     stxt6 = "Scan CDs/DVDs";
  92.     stxt7 = "Scan Folders";
  93.     loadActions();
  94.     }
  95.  
  96.  
  97.     mySetting.load();
  98.     imageIndex = mySetting.themeID;
  99.  
  100.     settingsUpdateIndex();
  101.   
  102.     scanActionIndex.value = scanaction;
  103.     this.chk1.checked = mySetting.bChk1;
  104.     this.chk2.checked = mySetting.bChk2;
  105.     this.chk3.checked = mySetting.bChk3;
  106.     this.chk4.checked = mySetting.bChk4;
  107.     this.chk5.checked = mySetting.bChk5;
  108.     this.chk6.checked = mySetting.bChk6;
  109.  
  110.     gOpt1.innerText = text1;
  111.     gOpt2.innerText = text2;
  112.     gOpt3.innerText = text3;
  113.     gOpt4.innerText = text4;
  114.     gOpt5.innerText = text5;
  115.     gOpt6.innerText = text6;
  116.  
  117.     gText1.innerText = gtxt1;
  118.     gText2.innerText = gtxt2;
  119.     gText3.innerText = gtxt3 + " ";
  120.  
  121.  
  122.     System.Gadget.onSettingsClosing = settingsClosing;
  123. }
  124.  
  125. function settingsUpdateImage(img, state)
  126. {
  127.     img.src = imagePath + "settings_" + img.src.split("_")[1] + "_" + state + ".png";
  128. }
  129.  
  130. function settingsButtonBack()
  131. {
  132.     if (event.keyCode == 32 || event.button == 1)
  133.     {
  134.         imageIndex--;
  135.         
  136.         if (imageIndex < 0)
  137.         {
  138.             imageIndex = imageArray.length - 1;
  139.         }
  140.         
  141.         settingsUpdateIndex();
  142.     }
  143. }
  144.  
  145. function settingsButtonForward()
  146. {
  147.     if (event.keyCode == 32 || event.button == 1)
  148.     {
  149.         imageIndex++;
  150.         
  151.         if (imageIndex == imageArray.length)
  152.         {
  153.             imageIndex = 0;
  154.         }
  155.         
  156.         settingsUpdateIndex();
  157.     }
  158. }
  159.  
  160. function settingsUpdateIndex()
  161. {
  162.     mySetting.themeID = imageIndex;
  163.     
  164.     settingsImagePreview.src = imagePath + imageArray[imageIndex];
  165.     currentIndex.innerHTML = imageIndex + 1;
  166.     maxIndex.innerHTML = imageArray.length;
  167. }
  168.  
  169. ////////////////////////////////////////////////////////////////////////////////
  170. // settings event closing
  171. ////////////////////////////////////////////////////////////////////////////////
  172. function settingsClosing(event)
  173. {
  174.     if (event.closeAction == event.Action.commit)
  175.     {
  176.         saveSettings();
  177.     }
  178. }
  179.  
  180. ////////////////////////////////////////////////////////////////////////////////
  181. // create object
  182. ////////////////////////////////////////////////////////////////////////////////
  183. function clockSettings()
  184. {   
  185.     this.save = saveSettingToDisk;
  186.     this.load = loadSettingFromDisk;
  187.     
  188.     this.themeID = 0;
  189.     this.scanActionIndex = 4;
  190.     scanaction = 4;
  191.  
  192.     this.bChk1 = true;
  193.     this.bChk2 = true;
  194.     this.bChk3 = true;
  195.     this.bChk4 = true;
  196.     this.bChk5 = true;
  197.     this.bChk6 = true;
  198.  
  199. }
  200.  
  201. ////////////////////////////////////////////////////////////////////////////////
  202. // load the information from disk
  203. ////////////////////////////////////////////////////////////////////////////////
  204. function loadSettingFromDisk()
  205. {
  206.     if (System.Gadget.Settings.read("SettingsExist"))
  207.     {
  208.     this.themeID = parseInt(System.Gadget.Settings.read("themeID"));
  209.     scanaction = parseInt(System.Gadget.Settings.read("scanActionIndex"));
  210.     this.bChk1 = System.Gadget.Settings.read("chk1");
  211.     this.bChk2 = System.Gadget.Settings.read("chk2");
  212.     this.bChk3 = System.Gadget.Settings.read("chk3");
  213.     this.bChk4 = System.Gadget.Settings.read("chk4");
  214.     this.bChk5 = System.Gadget.Settings.read("chk5");
  215.     this.bChk6 = System.Gadget.Settings.read("chk6");
  216.     }
  217. }
  218.  
  219. ////////////////////////////////////////////////////////////////////////////////
  220. // save information to disk
  221. ////////////////////////////////////////////////////////////////////////////////
  222. function saveSettingToDisk()
  223. {
  224.     System.Gadget.Settings.write("SettingsExist", true);
  225.     System.Gadget.Settings.write("themeID", this.themeID);
  226.     System.Gadget.Settings.write("scanActionIndex", this.scanActionIndex.value);
  227.     System.Gadget.Settings.write("chk1", this.bChk1);
  228.     System.Gadget.Settings.write("chk2", this.bChk2);
  229.     System.Gadget.Settings.write("chk3", this.bChk3);
  230.     System.Gadget.Settings.write("chk4", this.bChk4);
  231.     System.Gadget.Settings.write("chk5", this.bChk5);
  232.     System.Gadget.Settings.write("chk6", this.bChk6);
  233. }
  234.  
  235. ////////////////////////////////////////////////////////////////////////////////
  236. // save settings
  237. ////////////////////////////////////////////////////////////////////////////////
  238. function saveSettings()
  239. {
  240.     mySetting.scanActionIndex = scanActionIndex;
  241.     mySetting.bChk1 = this.chk1.checked;
  242.     mySetting.bChk2 = this.chk2.checked;
  243.     mySetting.bChk3 = this.chk3.checked;
  244.     mySetting.bChk4 = this.chk4.checked;
  245.     mySetting.bChk5 = this.chk5.checked;
  246.     mySetting.bChk6 = this.chk6.checked;
  247.     mySetting.save();
  248. }
  249.  
  250. ///////////////////////////////////////////////////////////////////////////////
  251. // load Actions
  252. ////////////////////////////////////////////////////////////////////////////////
  253. function loadActions()
  254. {
  255.     scanActionIndex.options[0] = new Option(stxt1, "1");
  256.     scanActionIndex.options[1] = new Option(stxt2, "2");
  257.     scanActionIndex.options[2] = new Option(stxt3, "3");
  258.     scanActionIndex.options[3] = new Option(stxt4, "4");
  259.     scanActionIndex.options[4] = new Option(stxt5, "5");
  260.     scanActionIndex.options[5] = new Option(stxt6, "6");
  261.     scanActionIndex.options[6] = new Option(stxt7, "7");
  262. }
  263.  
  264. ////////////////////////////////////////////////////////////////////////////////
  265. //
  266. // trim white space
  267. //
  268. ////////////////////////////////////////////////////////////////////////////////
  269. function trim(stringIn, removeFrom) 
  270.     var stringOut = "";
  271.     stringIn = stringIn.toString();
  272.     
  273.     if (stringIn.length > 0)
  274.     {
  275.         switch (removeFrom) 
  276.         { 
  277.             case "left": 
  278.                 stringOut = stringIn.replace(/^\s+/g, ""); 
  279.                 break; 
  280.             case "right": 
  281.                 stringOut = stringIn.replace(/\s+$/g, ""); 
  282.                 break; 
  283.             case "both":
  284.  
  285.             default:
  286.                 stringOut = stringIn.replace(/^\s+|\s+$/g, ""); 
  287.         }
  288.     }
  289.  
  290.     return stringOut;
  291. }
  292.